package com.cykj.v_m_sprintboot.serviceImpl;

import com.cykj.v_m_sprintboot.bean.TbCommodity;
import com.cykj.v_m_sprintboot.bean.TbCommorityCategory;
import com.cykj.v_m_sprintboot.bean.TbVmi;
import com.cykj.v_m_sprintboot.mapper.TbCommodityMapper;
import com.cykj.v_m_sprintboot.service.TbCommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("tcsi")
public class TbCommodityServiceIml implements TbCommodityService {
    @Autowired
    private TbCommodityMapper tbCommodityMapper;

    @Override
    public List<TbVmi> vmiInfo() {
        return tbCommodityMapper.vmiInfo();
    }

    @Override
    public void vmPay(String ComName,String goodsType,String goodsUnit,String categoryID,String ComNum,String orderTime,String vmid) {
        tbCommodityMapper.vmPay(ComName,ComNum,vmid);
        if((tbCommodityMapper.vmNum(ComName,ComNum,vmid)<=4)&&(tbCommodityMapper.vmState(ComName,ComNum,vmid) != 11)){
            tbCommodityMapper.vmApply(ComName,goodsType,goodsUnit,categoryID,ComNum,orderTime,vmid);
            tbCommodityMapper.vmStateApply(ComName,ComNum,vmid);
        }
    }

    @Override
    public void vmFundComm(String comImage,String conName,String conNum,String comPrice,String tradeNo) {
        tbCommodityMapper.vmFundComm(comImage,conName,conNum,comPrice,tradeNo);
    }

    @Override
    public void vmSup(String ComName,String ComNum,String vmid) {
        tbCommodityMapper.vmSup(ComName,ComNum,vmid);
        if((tbCommodityMapper.vmNum(ComName,ComNum,vmid)>4)){
        tbCommodityMapper.vmStateNormal(ComName,ComNum,vmid);
        }
    }

    @Override
    public void vmOrder(String tradeNo,String fundName,String fundTime,String fundState,String fundMoney,
                        String fundNum,String payMethod,String VMID,String openID) {
        tbCommodityMapper.vmOrder(tradeNo,fundName,fundTime,fundState,fundMoney,fundNum,payMethod,VMID,openID);
        tbCommodityMapper.vmCapital(fundMoney,VMID);
    }

    @Override
    public int selcommdity() {
        return tbCommodityMapper.selcommdity();
    }

    @Override
    public List<TbCommodity> selcommdityPage(int page, int size,int vmid,int cateid) {
        System.out.println(page+","+size+"-----"+vmid+"---111"+cateid);
        return tbCommodityMapper.selcommdityPage(page,size,vmid,cateid);
    }

    @Override
    public List<TbCommodity> selectCommList(int vmid,int cateid,int page1,int size1) {
        System.out.println(vmid+"-=890=-"+cateid+page1+"==098"+size1);
        return tbCommodityMapper.selectCommList(vmid,cateid,page1,size1);
    }

    @Override
    public void updateCommodity(int comNum,int comId,String comName,String comPrice) {
        tbCommodityMapper.updateCommodity(comNum,comId,comName,comPrice);
    }

    @Override
    public void delCommodity(int comId) {
        tbCommodityMapper.delCommodity(comId);
    }

    @Override
    public void insComm(String comImage, String comName, String comPrice ,int cateid, int vmid, int comNum) {
        System.out.println(vmid+comName+comPrice+comNum+comImage+"新增"+cateid);
        tbCommodityMapper.insComm(comImage,comName,comPrice,cateid,vmid,comNum);
    }


}
